package com.newdjk.newdoctor.utils;

import com.newdjk.newdoctor.MyApplication;
import com.newdjk.newdoctor.db.gen.DaoSession;
import com.newdjk.newdoctor.db.gen.PushDataDaoEntityDao;
import com.newdjk.newdoctor.entity.PushDataDaoEntity;

import java.util.ArrayList;
import java.util.List;

public class SqlUtils {
    private static SqlUtils instance;
    private final PushDataDaoEntityDao pushDataDaoEntityDao;

    private SqlUtils() {
        pushDataDaoEntityDao = MyApplication.getDbSession().getPushDataDaoEntityDao();

    }

    public static SqlUtils getInstance() {
        if (instance == null) {
            synchronized (SqlUtils.class) {
                if (instance == null) {
                    instance = new SqlUtils();
                }
            }
        }
        return instance;
    }
    //条件查询
    public List<PushDataDaoEntity> selectAllContactsByDoctorId(String accountId) {
        List<PushDataDaoEntity> list1 = pushDataDaoEntityDao.queryBuilder().where(PushDataDaoEntityDao.Properties.AccountId.eq(accountId)).orderDesc(PushDataDaoEntityDao.Properties.Time).list();
        return list1 == null ? new ArrayList<PushDataDaoEntity>() : list1;
    }
}
